import {createAction, createThunkAction} from "../../lib/redux-utils";
import {get, postJson} from "../../lib/http";
import {getPrincipal} from "../../lib/identity";

const principal = getPrincipal();
const path = "/zadOrder";
const ACTION_PREFIX = "ZAD_ORDER_RECEIVABLE.";
export const query = createThunkAction(ACTION_PREFIX + "QUERY", params =>
    postJson(path + "/query", params)
);
export const showCreate = createAction(ACTION_PREFIX + "SHOW_CREATE");
export const hideCreate = createAction(ACTION_PREFIX + "HIDE_CREATE");
export const showExport = createAction(ACTION_PREFIX + "SHOW_EXPORT_R");
export const hideExport = createAction(ACTION_PREFIX + "HIDE_EXPORT_R");
export const showEditDateAndRemarkModal = createAction(ACTION_PREFIX + "SHOW_EDIT_DATE_AND_REMARK");
export const hideEditDateAndRemarkModal = createAction(ACTION_PREFIX + "HIDE_EDIT_DATE_AND_REMARK");
export const updateEditDateAndRemarkModal = createAction(ACTION_PREFIX + "UPDATE_EDIT");
export const showEdit = createAction(ACTION_PREFIX + "SHOW_EDIT");
export const hideEdit = createAction(ACTION_PREFIX + "HIDE_EDIT");
export const showCreateOrderFee = createAction(ACTION_PREFIX + "SHOW_CREATE_ORDER_FEE");
export const hideCreateOrderFee = createAction(ACTION_PREFIX + "HIDE_CREATE_ORDER_FEE");
export const showColumns = createAction(ACTION_PREFIX + "SHOW_COLUMNS");
export const hideColumns = createAction(ACTION_PREFIX + "HIDE_COLUMNS");
export const showUpdateOrderFee = createAction(ACTION_PREFIX + "SHOW_UPDATE_ORDER_FEE");
export const hideUpdateOrderFee = createAction(ACTION_PREFIX + "HIDE_UPDATE_ORDER_FEE");
export const showUpdateOrderOutFee = createAction(ACTION_PREFIX + "SHOW_UPDATE_ORDER_OUT_FEE");
export const hideUpdateOrderOutFee = createAction(ACTION_PREFIX + "HIDE_UPDATE_ORDER_OUT_FEE");
export const updateOrderFee = createAction(ACTION_PREFIX + "UPDATE_ORDER_FEE");
export const updateOrderOutFee = createAction(ACTION_PREFIX + "UPDATE_ORDER_OUT_FEE");
export const updateOrderFollows = createAction(ACTION_PREFIX + "UPDATE_ORDER_FOLLOWS");
export const updateOrderModel = createAction(ACTION_PREFIX + "UPDATE_MODEL");
export const updateExportModel = createAction(ACTION_PREFIX + "UPDATE_EXPORT_MODEL");
export const select = createAction(ACTION_PREFIX + "SELECT");
export const showExportLog = createAction(ACTION_PREFIX + "SHOW_EXPORT_LOG");
export const hidExportLog = createAction(ACTION_PREFIX + "HIDE_EXPORT_LOG");
export const updateDataSource = createAction(ACTION_PREFIX + "UPDATE_DATA_SOURCE");
export const showPartExport = createAction(ACTION_PREFIX + "SHOW_PART_EXPORT");
export const hidePartExport = createAction(ACTION_PREFIX + "HIDE_PART_EXPORT");
export const updateRateDataSource = createAction(ACTION_PREFIX + "UPDATE_RATE_DATA");

export const create = createThunkAction(ACTION_PREFIX + "CREATE", params =>
    postJson(path + "/create", params)
);
export const modify = createThunkAction(ACTION_PREFIX + "MODIFY", params =>
    postJson(path + "/modify", params)
);
export const modifyPart = createThunkAction(ACTION_PREFIX + "", params =>
    postJson(path + "/modifyPart", params)
);
export const getCurrencyList = createThunkAction(ACTION_PREFIX + "GET_CURRENCY", () =>
    get("/rate/currency")
);
export const getFeeList = createThunkAction(ACTION_PREFIX + "GET_FEE_LIST", () =>
    get("/feeItem/all")
);
export const getRateList = createThunkAction(ACTION_PREFIX + "GET_RATE", () =>
    get("/rate/all")
);
export const getBusinessCodeList = createThunkAction(ACTION_PREFIX + "GET_BUSINESS_CODE_LIST", () =>
    get("/bsCode/all")
);
export const del = createThunkAction("", params =>
    get(path + "/del/" + params + "/" + principal.id)
);
export const getMyColumns = createThunkAction(ACTION_PREFIX + "GET_COLUMNS", params =>
    get("/customColumns/" + principal.id + "/" + params)
);
export const lock = createThunkAction(ACTION_PREFIX + "LOCK", params =>
    postJson(path + "/lock/" + principal.id, params)
);
export const unlock = createThunkAction(ACTION_PREFIX + "UN_LOCK", params =>
    postJson(path + "/unlock/" + principal.id, params)
);
export const selectColumns = createAction(ACTION_PREFIX + "GET_COLUMNS");
export const saveColumns = createThunkAction(ACTION_PREFIX + "SAVE_COLUMNS", params =>
    postJson("/customColumns/modify", params)
);
export const getFollows = createThunkAction(ACTION_PREFIX + "GET_FOLLOWS", params =>
    get(path + "/findFollows/" + params)
);
export const queryExportLog = createThunkAction(ACTION_PREFIX + "QUERY_EXPORT_LOG", params =>
    get("/zadOrder/exportLog/zadOrderReceivable/IN/" + principal.id)
);
// 锁定解锁费用
export const lockFee = createThunkAction(ACTION_PREFIX + "LOCK_FEE", params =>
    postJson("/orderFee/lockFee/" + principal.id, params)
);
export const unlockFee = createThunkAction(ACTION_PREFIX + "UNLOCK_FEE", params =>
    postJson("/orderFee/unlockFee/" + principal.id, params)
);
export const updateFee = createThunkAction(ACTION_PREFIX + "UPDATE_FEE", params =>
    postJson("/orderFee/updateFee/" + principal.id, params)
);
export const lockFeeById = createThunkAction(ACTION_PREFIX + "LOCK_FEE_BY_ID", params =>
    get("/orderFee/lockFee/" + principal.id + "/" + params)
);
export const unlockFeeById = createThunkAction(ACTION_PREFIX + "UNLOCK_FEE_BY_ID", params =>
    get("/orderFee/unlockFee/" + principal.id + "/" + params)
);
export const changeInvoice = createThunkAction(ACTION_PREFIX + "CHANGE_INVOICE", params =>
    postJson(path + "/changeInvoice/IN/" + principal.id, params)
);
export const changeSettlement = createThunkAction(ACTION_PREFIX + "CHANGE_SETTLEMENT", params =>
    postJson(path + "/changeSettlement/IN/" + principal.id, params)
);
export const changeInvoice2 = createThunkAction(ACTION_PREFIX + "CHANGE_INVOICE2", params =>
    postJson(path + "/invoiceOrder", params)
);
export const changeSettlement2 = createThunkAction(ACTION_PREFIX + "CHANGE_SETTLEMENT2", params =>
    postJson(path + "/settlementOrder", params)
);
export const reCalculateFee = createThunkAction(ACTION_PREFIX + "RE_CALCULATE_FEE", params =>
    postJson(path + "/reCalculateFee", params)
);
export const feeList = createThunkAction(ACTION_PREFIX + "FEE_LIST_BY_ID", params =>
    get(path+ "/feeList/" + params)
);
export const partExportByType3 = createThunkAction(ACTION_PREFIX + "EXPORT", params =>
    postJson(path + "/partExportByType3", params)
);
export const unSetOrder = createThunkAction(ACTION_PREFIX + "UNSETORDER", params =>
    postJson(path + "/unSetOrder/IN", params)
);